package com.example.administrator.newsdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    ArrayList<News> newsArrayList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //初始化界面所需的数据
        initData();

        //初始化界面
        initView();

    }
    private void initData(){
        //read String str from news.json
        String str = readNewsJsonFile();
        //parse str to ArrayList<News>
        newsArrayList = parseJson(str);


    }
    private ArrayList<News> parseJson(String str){
        ArrayList<News> newsList = new ArrayList<>();
        News news = new News();
    }
    private String readNewsJsonFile(){
        //TODO 等会要从news.json中读取，现在暂时用固定字符串先临时用一下
        return  "[\n" +
                "  {\n" +
                "    \"icon\":\"a.jpg\",\n" +
                "    \"title\":\"科技温暖世界\",\n" +
                "    \"content\":\"进入一个更有爱的领域\",\n" +
                "\t\"type\":\"1\",\n" +
                "\t\"comment\":\"69\"\n" +
                "  },\n" +
                "  {\n" +
                "\t\"icon\":\"b.jpg\",\n" +
                "\t\"title\":\"《神武》\",\n" +
                "\t\"content\":\"新美术资源盘点 视觉新体验\",\n" +
                "\t\"type\":\"2\",\n" +
                "\t\"comment\":\"35\"\n" +
                "  },\n" +
                "  {\n" +
                "\t\"icon\":\"c.jpg\",\n" +
                "\t\"title\":\"南北车正式公布合并\",\n" +
                "\t\"content\":\"南北车将于今日正式公布合并\",\n" +
                "\t\"type\":\"3\",\n" +
                "\t\"comment\":\"2\"\n" +
                "  },\n" +
                "  {\n" +
                "\t\"icon\":\"d.jpg\",\n" +
                "\t\"title\":\"萌呆了！汪星人抱玩偶酣睡\",\n" +
                "\t\"content\":\"汪星人抱玩偶酣睡,萌翻网友\",\n" +
                "\t\"type\":\"1\",\n" +
                "\t\"comment\":\"25\"\n" +
                "  },\n" +
                "  {\n" +
                "\t\"icon\":\"e.jpg\",\n" +
                "\t\"title\":\"风力发电进校园\",\n" +
                "\t\"content\":\"风力发电普进校园\",\n" +
                "\t\"type\":\"2\",\n" +
                "\t\"comment\":\"26\"\n" +
                "  },\n" +
                "  {\n" +
                "\t\"icon\":\"f.jpg\",\n" +
                "\t\"title\":\"地球一小时\",\n" +
                "\t\"content\":\"地球熄灯一小时\",\n" +
                "\t\"type\":\"1\",\n" +
                "\t\"comment\":\"23\"\n" +
                "  },\n" +
                "  {\n" +
                "\t\"icon\":\"g.jpg\",\n" +
                "\t\"title\":\"最美公路\",\n" +
                "\t\"content\":\"最美公路 难以想象\",\n" +
                "\t\"type\":\"1\",\n" +
                "\t\"comment\":\"23\"\n" +
                "  }\n" +
                "]\n";
    }

    class News{
        private String icon;
        private String title;
        private String content;
        private String type;

        public String getIcon() {
            return icon;
        }

        public void setIcon(String icon) {
            this.icon = icon;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getComment() {
            return comment;
        }

        public void setComment(String comment) {
            this.comment = comment;
        }

        private String comment;
        /*
        {
    "icon":"a.jpg",
    "title":"科技温暖世界",
    "content":"进入一个更有爱的领域",
	"type":"1",
	"comment":"69"
  },
         */
    }
}
